Skip to content

Conversation

TimG1964
Copy link
Contributor

I've added a copy function and some associated tests. It recursively copies a node and all its children. A little discussion on Discourse, here.

I've added some tests for this, too.

The Readme page says:

  • Node is an immutable type. However, you can easily create a copy with one or more field values changed by using the Node(::Node; kw...) constructor where kw are the fields you want to change. For example:
node = XML.Element("tag", XML.Text("child"))

simple_value(node)
# "child"

node2 = Node(node, children=XML.Text("changed"))

simple_value(node2)
# "changed"

I think this is probably out of date. The Node() function now seems to treat arguments as (new) children and keywords as new/changed attributes. I've changed the text here to reflect this and added a reference to copy().

TimG1964 and others added 4 commits February 12, 2025 10:59
Speculative suggestion.
Tests pass locally but I think this needs deeper understanding than I can bring.
Change `setindex!()` to deal with case when `XML.attributes(node) === nothing`
@TimG1964
Copy link
Contributor Author

Something strange here. There are old changes in the code I thought I'd removed when I synced my fork just now. Evidently not! I'll close this and try harder!

@TimG1964 TimG1964 closed this May 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant